home *** CD-ROM | disk | FTP | other *** search
- /* Reads arguments from CLI or Workbench, and calls sMOVIE's parser
- to act on the specified files.
-
- Martin J. Round 16-Oct-89
- */
-
- #include "sMOVIE.h"
-
- extern void parse (FILE *,int);
-
- extern void message (UBYTE *);
-
- extern void print (char *);
-
- extern void free_memory (int);
-
- extern int runningfromcli;
-
- extern char line[MAXLINE + 1], buff[MAXLINE * 2];
-
- extern struct WBStartup *WBenchMsg;
-
- FILE *fp, *fopen();
-
- BPTR olddir;
-
- void argread (argc, argv, pass)
- int argc;
- char **argv;
- int pass;
-
- {
- int i;
-
- /* Check we've got something to do */
- if (runningfromcli && argc == 1) {
- print("Useage: sMOVIE filename [filename]....\n");
- free_memory(4);
- exit(0L);
- }
-
- if (!runningfromcli &&
- ((WBenchMsg == NULL) || (WBenchMsg->sm_NumArgs < 2))) {
- message ("You must click on a project - try 'sMOVIE.readme'.");
- free_memory(4);
- exit(0L);
- }
-
- /* process config file first (if it exists) */
- /* look first in root dir if fail try s: */
-
- if ((fp = fopen(CONFIGFILENAME1,"r")) ||
- (fp = fopen(CONFIGFILENAME2,"r"))) {
- parse(fp,pass);
- fclose(fp);
- }
-
- if (runningfromcli) {
- for (i=1; i<argc; i++) {
- if ((fp = fopen(argv[i],"r")) == NULL) {
- if (pass == 0) {
- sprintf(buff,"Can't open file: %s\n",argv[i]);
- print(buff);
- }
- }
- else {
- parse(fp,pass);
- fclose(fp);
- }
- }
- }
- else { /* running from Workbench */
- for (i=1; i<WBenchMsg->sm_NumArgs; i++) {
- olddir = CurrentDir (WBenchMsg->sm_ArgList[i].wa_Lock);
- if ((fp = fopen(WBenchMsg->sm_ArgList[i].wa_Name,"r")) == NULL) {
- if (pass == 0) {
- sprintf(buff,"Can't open file: %s",
- WBenchMsg->sm_ArgList[i].wa_Name);
- message(buff);
- }
- }
- else {
- parse(fp,pass);
- fclose(fp);
- }
- if (olddir) CurrentDir(olddir);
- }
- }
- }